Frontend Forever App
We have a mobile app for you to download and use. And you can unlock many features in the app.
Get it now
Intall Later
Run
HTML
CSS
Javascript
Output
Document
Analog Clock - the code school
1
2
3
4
5
6
7
8
9
10
11
12
@charset "UTF-8"; @import url(https://fonts.googleapis.com/css?family=Nunito+Sans:300,400,600,700,800); *, :after, :before { box-sizing: border-box; padding: 0; margin: 0; } *{ margin: 0; padding: 0; box-sizing: border-box; font-family: sans-serif; color: #fff; } body{ /*background: rgb(33,33,34);*/ min-height: 100vh; display: flex; justify-content: center; align-items: center; } .container{ /*background: rgba(255,255,255,0.05);*/ background:gray; border-radius: 50%; padding: 10px; outline: 10px solid #3b3831; outline-offset: 5px; box-shadow: 0 0 80px #000; } .clock{ position: relative; border-radius: 50%; width: 500px; height: 500px; display: flex; justify-content: center; align-items: center; border: 20px solid #181229; outline: 10px solid rgb(108,108,108); outline-offset: -20px; } .clock span{ position: absolute; transform: rotate(calc(30deg * var(--j))); inset: 20px; text-align: center; } .clock span b{ transform: rotate(calc(-30deg * var(--j))); display: inline-block; font-size: 24px; font-weight: 700; height: 50px; width: 50px; } .clock::before{ content: ''; position: absolute; width: 10px; height: 10px; border-radius: 50%; background: #fff; z-index: 1; } .hand{ position: absolute; display: flex; justify-content: center; align-items: flex-end; } .hand i{ position: absolute; background: var(--clr); height: var(--ht); width: var(--wt); z-index: 0; }
console.log("Event Fired") let hour = document.getElementById('hour') let minute = document.getElementById('minute') let second = document.getElementById('second') function displayTime(){ let date = new Date(); let hh = date.getHours(); let mm = date.getMinutes(); let ss = date.getSeconds(); let hRotation = 30* hh + mm/2 + ss/120; let mRotation = 6 * mm + ss/10 let sRotation = 6 * ss; hour.style.transform = `rotate(${hRotation}deg)` minute.style.transform = `rotate(${mRotation}deg)` second.style.transform = `rotate(${sRotation}deg)` } setInterval(displayTime,1000)